﻿using Communergy.Common;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
namespace Communergy.Common.Tests
{
    
    
    /// <summary>
    ///This is a test class for EnergyReadingTest and is intended
    ///to contain all EnergyReadingTest Unit Tests
    ///</summary>
    [TestClass()]
    public class EnergyReadingTest
    {


        /// <summary>
        ///A test for EnergyReading Constructor
        ///</summary>
        [TestMethod()]
        public void EnergyReading_WattsConstructor_CheckKWh()
        {
            DateTime dateTime = DateTime.Now;
            TimeSpan timeSpan = new TimeSpan(0, 0, 6);
            int watts = 600000;

            EnergyInformation target = new EnergyInformation(dateTime, timeSpan, watts);
            decimal kWh = 1.0M;
            Assert.AreEqual(kWh, target.KWh);            
        }

        [TestMethod()]
        public void EnergyReading_WattsConstructor_CheckAverageWatts()
        {
            DateTime dateTime = DateTime.Now;
            TimeSpan timeSpan = new TimeSpan(0, 0, 6);
            int joules = 60;

            EnergyInformation target = new EnergyInformation(dateTime, timeSpan, joules);
            decimal expectedAverageWatts = 60M;
            Assert.AreEqual(expectedAverageWatts, target.AverageWatts);
        }




        [TestMethod()]
        public void EnergyReading_CheckReadingPeriodEnd_ShouldBe10MinutesLater()
        {
            DateTime dateTime = new DateTime(2010, 5, 21, 0, 29, 0);
            TimeSpan timeSpan = new TimeSpan(0, 10, 0);
            decimal kWh = 1.0M;
            EnergyInformation target = new EnergyInformation(dateTime, timeSpan, kWh);
            DateTime expectedEndTime = new DateTime(2010, 5, 21, 0, 39, 0);
            Assert.AreEqual<DateTime>(expectedEndTime, target.PeriodEnd);
        }

    }
}
